\documentclass{article}
\usepackage{ctex} % 中文支持
\usepackage{tikz} % 用于绘图
\usetikzlibrary{shapes,arrows,arrows.meta,3d, angles, quotes}
\usepackage{tikz-3dplot}

\usepackage{geometry} % 文档四周边界
\geometry{a4paper, left=2.5cm, right=2.5cm, top=1.5cm, bottom=1.5cm}

\begin{document}

\title{立体几何图示例}
\author{作者名}
\date{\today}
\maketitle

\section{平面几何图示例}

下面是一个使用TikZ宏包绘制的平面几何图示例：

\begin{figure}[h]
    \centering
    \begin{tikzpicture}[scale=1.0, >=Stealth, thick]

        % 定义点的位置
        \coordinate (A) at (0,0);
        \coordinate (B) at (2,1);
        \coordinate (P) at (3,1.5);

        \coordinate (M) at (0,1);
        \coordinate (N) at (2,2);

        % 绘制向量a
        \draw[->, -{Stealth[scale=1.5]}, thick] (M) -- (N) node[midway, above left] {$a$};
        \fill[blue] (M) circle (1.5pt);% node[below left] {$M$};
        \fill[blue] (N) circle (1.5pt);% node[above right] {$B$};

        % 绘制直线ell
        \draw[dashed] (-1,-0.5) -- (4,2) node[right]{$\ell$};

        % 绘制λa (λ>0)
        \draw[->, -{Stealth[scale=1.5]}, thick, red] (A) -- (B);
        \draw[->, -{Stealth[scale=1.5]}, thick, purple] (A) -- (P);

        \fill[blue] (A) circle (1.5pt) node[below right] {$A$};
        \fill[blue] (B) circle (1.5pt) node[below right] {$B$};
        \fill[blue] (P) circle (1.5pt) node[below right] {$P$};

    \end{tikzpicture}
    \caption{一个平面几何图}
    \label{fig-1}
\end{figure}

\section{立体几何图示例}

下面是一个使用TikZ宏包绘制的立体几何图示例：

% 设置观察角度，第一个参数是绕x轴旋转的角度，第二个是绕z轴旋转的角度
\tdplotsetmaincoords{70}{120} 

\begin{figure}[h]
    \centering
    \begin{tikzpicture}[scale=1.0, >=stealth, tdplot_main_coords]

        \coordinate (D) at (0,0,0);
        \coordinate (A) at (3,0,0);
        \coordinate (B) at (3,4,0);
        \coordinate (C) at (0,4,0);
        \coordinate (A1) at (3,0,2);
        \coordinate (B1) at (3,4,2);
        \coordinate (C1) at (0,4,2);
        \coordinate (D1) at (0,0,2);

        % 标记点
        \fill[blue] (A) circle (1.5pt) node[above left] {$A$};
        \fill[blue] (B) circle (1.5pt) node[below right] {$B$};
        \fill[blue] (C) circle (1.5pt) node[below right] {$C$};
        \fill[blue] (D) circle (1.5pt) node[below right] {$D$};
        \fill[blue] (A1) circle (1.5pt) node[above left] {$A_1$};
        \fill[blue] (B1) circle (1.5pt) node[above left] {$B_1$};
        \fill[blue] (C1) circle (1.5pt) node[above right] {$C_1$};
        \fill[blue] (D1) circle (1.5pt) node[above right] {$D_1$};

        % 线段
        \draw[thick] (A) -- (B) -- (C);
        \draw[dashed] (C) -- (D) -- (A);
        \draw[thick] (A1) -- (B1) -- (C1) -- (D1) -- cycle;
        \draw[thick] (A) -- (A1);
        \draw[thick] (B) -- (B1);
        \draw[thick] (C) -- (C1);
        \draw[dashed] (D) -- (D1);

        % 有些面给阴影
        \fill[blue!20, opacity=0.5] (B) -- (C) -- (C1) -- (B1) -- cycle;

        % 延长得到坐标轴
        \draw[->, -{Stealth[scale=1.5]}, thick] (A) --++ (1,0,0) node[left] {$\mathbf{x}$};
        \draw[->, -{Stealth[scale=1.5]}, thick] (C) --++ (0,1,0) node[right] {$\mathbf{y}$};
        \draw[->, -{Stealth[scale=1.5]}, thick] (D1) --++ (0,0,1) node[above] {$\mathbf{z}$};

        % 待研究的点、线段
        \coordinate (M) at (3,2,0);
        \draw[thick,purple] (A1) -- (M);
        \draw[dashed,purple] (M) -- (C);
        \draw[dashed,purple] (A1) -- (C);
        \fill[purple] (M) circle (1.5pt) node[below] {$M$};

    \end{tikzpicture}
    \caption{一个立体几何图}
    % \label{fig-2}
\end{figure}

\end{document}